function registerUseronClick(){
	var userName = $id("txtUsernameId").value;
	var password = $id("txtPasswordId").value;
	var repeatPassword = $id("txtRepeatPasswordId").value;
	var email = $id("txtEmailId").value;
	var lastName = $id("txtLastnameId").value;
	var firstName = $id("txtFirstnameId").value;
	var address = $id("txtAddressId").value;
	var phoneNumber = $id("txtPhoneNumberId").value;
	if(validateInputRegister(userName,password,repeatPassword,email)){
		ajax.put({
						url : "http://localhost:8080/book-service/public/book/authen/register",
			param : {
				"userName" : userName,
				"passWord" : password,
				"email" : email,
				"firstName" : firstName,
				"lastName" : lastName,
				"phone" : phoneNumber,
				"address" : address
			},

			success : function(data, xhr) {
				console.log(data);

				$id("login").addClass("hide");
				$id("profile").removeClass("hide");
				$id("panel").addClass("hide");
			var avatar = data.getElementsByTagName("avatar")[0].childNodes[0].nodeValue;
			
	        $id("profileUserName").innerText= userName.substring(0,5);
	   		$id("icon-avatar").src =avatar;
	        $id("profilePicture").src= avatar;
			$id("profileUserName").innerText = userName.substring(0, 5);
			$id("icon-avatar").src = avatar;
			$id("profilePicture").src = avatar;
			
			hidePopup();
			},
			failure : function(xhr) {
				alert("Login fail");
				//pagesManager.hideLoading();
			},
			abort : function(xhr) {
				callback.abort(xhr);
			}
		});
	}
	
}

function validateInputRegister(userName,password,repeatPassword,email){
	if(!userName){
		alert("Xin hãy nhập userName");
		return false;
	}else if(!password){
		alert("Xin hãy nhập password");
		return false;
	}else if(!email){
		alert("xin hãy nhập email");
		return false;
	}else if(password!=repeatPassword){
		alert("Password nhập lại không giống với password");
		return false;
	}
	return true;
	
	
}
